/*
 * Gusfield, Algorithms on Strings, Trees, and Sequences
 * p.9, The Z algorithm
 * 
 * Tested on http://www.algospot.com/judge/problem/read/NAMING
 */

#include<cstdio>
#include<algorithm>
#include<cstring>

#define N 400005
using namespace std;

int n;
char str[N];
int z[N];
int main(){
    int i,j,k;
    scanf("%s", &str);
    n = strlen(str);
    scanf("%s", &str[n]);
    n = strlen(str);
    z[0] = 0;
    int l, r;
    l = r = 0;
    for (i = 1; i < n;i++) {
        if (i > r) {
            for (j = 0; j < n - i; j++){
                if (str[i + j] != str[j]) {
                    z[i] = j;
                    if (z[i] != 0) {
                        r = i + j - 1;
                        l = i;
                    }
                    break;
                } else if (j == n - i - 1) {
                    z[i] = j + 1;
                    r = n - 1;
                    l = i;
                }
            }
        } else {
            j = i-l;
            if (z[j] < r - i + 1) {
                z[i] = z[j];
            } else {
                j = r - i + 1;
                z[i] = j;
                l = i;
                for (k = 0; k < n - (r + 1); k++){
                    if (str[r + 1 + k] != str[j + k]) {
                        z[i] = j + k;
                        r = r + k;
                        l = i;
                        break;
                    } else if (k == n - (r + 1) -1) {
                        z[i] = j + k + 1;
                        r = n - 1;
                        l = i;
                    }
                }
            }
        }
    }
    z[0] = n;
    for (i = n - 1; i >= 0; i--){
        if (z[i] == n - i)
            printf("%d ", z[i]);
    }
    printf("\n");
    return 0;
}
